import baseservice from './baseservice.js'
export default {
	getPageData(self, successBack, errorBack) {
		baseservice.getPageData(self, self.apis.roleList, self.searchcondition);
	},
	showDetail(self, row, title) {
		baseservice.showDetail(self, row, title);
	},
	handleDetail(self, id, successBack, errorBack) {
		
		console.log(id)
		let param = {};
		param.operUserId = id;
		self.httptool.ajaxAsyncPost('backend/operuser/detail',param, function(res) {
			if(res.code==1) {
				self.modelData = res.data;
			}
		});

	},
	
	handleSave(self, successBack, errorBack) {
		let that = this;
		let rule = [{
			name:'operUserName',
			label:'运维人员姓名',
			rule: ['validateEmpty_']
		},{
			name:'operUserPhone',
			label:'联系电话',
			rule: ['validateTel_']
		},{
			name:'operUserAge',
			label:'年龄',
			rule: ['validateNum_']
		},{
			name:'operUserIdCard',
			label:'身份证',
			rule: ['validateID_'],
			emptyOrRequire:true
		},{
			name:'parkId',
			label:'停车场',
			rule: ['validateEmpty_']
		}]
	
		let requestUrl = self.apis.addPark;
		let msg ;
    	if(self.parkId){
    		msg = '编辑成功'
    	}else{
    		msg = '添加成功'
    	}
		if(!self.validatetool.validate(self,self.modelData,rule)){
    		return; 
    	}     
		self.httptool.ajaxAsyncPost('backend/operuser/save', self.modelData, function(res) {
			if(res.code==1) {
				self.$message({
					message: msg,
					type: 'success'
				});
				self.priDialogFormVisible = false;
				that.getPageData(self);
				self.$emit('close', true);
			} else {
				self.$message(res.msg);
			}
		});
		
	}
}